@model cloudscribe.Core.Web.ViewModels.SiteUser.TwoFactorAuthenticationViewModel
@inject IStringLocalizer<CloudscribeCore> sr
@{
    ViewData["BodyClass"] = "manage-section manage-2fa";

}
<h4>@ViewData["Title"]</h4>
@if (Model.Is2faEnabled)
{
    if (Model.RecoveryCodesLeft == 0)
    {
        <div class="alert alert-danger">
            <strong>@sr["You have no recovery codes left."]</strong>
            <p>You must <a asp-action="GenerateRecoveryCodes">generate a new set of recovery codes</a> before you can log in with a recovery code.</p>
        </div>
    }
    else if (Model.RecoveryCodesLeft == 1)
    {
        <div class="alert alert-danger">
            <strong>@sr["You have 1 recovery code left."]</strong>
            <p>You can <a asp-action="GenerateRecoveryCodes">generate a new set of recovery codes</a>.</p>
        </div>
    }
    else if (Model.RecoveryCodesLeft <= 3)
    {
        <div class="alert alert-warning">
            <strong>You have @Model.RecoveryCodesLeft recovery codes left.</strong>
            <p>You should <a asp-action="GenerateRecoveryCodes">generate a new set of recovery codes</a>.</p>
        </div>
    }

    @if (!Model.Is2faRequiredByAdmin)
    {
        <a asp-action="Disable2faWarning" class="btn btn-primary">@sr["Disable 2FA"]</a>
    }

    <a asp-action="GenerateRecoveryCodes" class="btn btn-primary">@sr["Reset recovery codes"]</a>
}

<h5>@sr["Authenticator app"]</h5>
@if(Model.Is2faRequiredByAdmin)
{
    <p>
        @sr["The administrators of this site require all users to enable 2 factor authentication to meet the security requirements of this site."]
    </p>
}
@if (!Model.HasAuthenticator)
{
    <a asp-action="EnableAuthenticator" class="btn btn-primary">@sr["Add authenticator app"]</a>
}
else
{
    <a asp-action="EnableAuthenticator" class="btn btn-primary">@sr["Configure authenticator app"]</a>
    <a asp-action="ResetAuthenticatorWarning" class="btn btn-primary">@sr["Reset authenticator key"]</a>
}

@section Scripts {
    <script src="~/cr/js/jquery.validate.min.js"></script>
    <script src="~/cr/js/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/cr/js/unobtrusive-validation-bs4.min.js"></script>
}
